Delete build.py
[Misc-UserScripts.git] / Press '.' and do Quoting things on 4chanX.user.js
blobb55853d373e055db69f63f4545161768156c15b8
1 // ==UserScript==
2 // @name         Press "." and do Quoting things on 4chanX
3 // @namespace    http://tampermonkey.net/
4 // @version      1.1
5 // @description  Allows you to quote text without creating a quote link item in your post
6 // @author              ECHibiki - Sage
7 // @match        *://boards.4chan.org/*
8 // @grant        none
9 // ==/UserScript==
12 var THAT_FIELD_YOU_CHANGE_TO_SET_YOUR_HOTKEY_CHARACTER = ".";
16 var qr_open = false;
18 document.addEventListener("keydown", function(e){
19         if(e.key == THAT_FIELD_YOU_CHANGE_TO_SET_YOUR_HOTKEY_CHARACTER && !(document.activeElement.tagName == "INPUT" || document.activeElement.tagName == "TEXTAREA")){
20                 var text = getSelectionText().split("\n");
21         var intermed = text;
22         text = (text.map(function(line){return line.trim() != "" ? ">" + line : line;})).join("\n");
23                 e.preventDefault();
24                 e.stopPropagation();
25                 if(!qr_open) document.getElementsByClassName("qr-link")[0].click();
26                 setTimeout(function(){
27                         document.getElementById("qr").getElementsByTagName("TEXTAREA")[0].value += text + "\n";
28                 },100);
29                 return false;
30         }
31 });
35 function getSelectionText() {
36     var text = "";
37     if (window.getSelection) {
38         text = window.getSelection().toString();
39     } else if (document.selection && document.selection.type != "Control") {
40         text = document.selection.createRange().text;
41     }
42     return text;